<?php
// 本文档自动生成，仅供测试运行
class ContentAction extends Action
{

	/**
	 * ------------------------------
	 * 预处理
	 * ------------------------------
	 */
	function _initialize(){
		if( !isset($_SESSION['adm_name']) or !isset($_SESSION['isAdmin']) ) $this->redirect('Index/login');
	}

	 
    /**
	 * ------------------------------
	 * 搜索微博
	 * ------------------------------
	 */
	function search(){
		 $name=$_REQUEST['name'];
		 $this->assign('name',$name);	 	
		import("@.ORG.Page");
		$count	= M('weibo')->where("content like '%$name%'")->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('weibo')->where("content like '%$name%'")->order('time desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();

		
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '搜索微博列表');
	
		$this->display('weibo');
	 }	

 

	/**
	 * ------------------------------
	 * 文章管理
	 * ------------------------------
	 */
	function article(){
	
		import("@.ORG.Page");
		$count	= M('article')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('article')->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '文章列表');
	
		$this->display();
	 }
	
	function editarticle(){
        $id = intval($_GET['id']);
		$shop = M('shop')->order('ctime desc,id desc')->select();
	    $this->assign('shop', $shop);
		$areas = M('pz_area')->order('ctime desc,id desc')->select();
	    $this->assign('areas', $areas);
		$menus = M('pz_menu')->where("mid=0")->order('xu asc,id desc')->select();
	    $this->assign('menus', $menus);
	    $this->assign('menusr', $menus);
	    $this->assign('menusl', $menus);
		if($id==''){
			$this->assign('pagetitle', '添加文章');
		}else{
			$list = M('article')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$this->assign($list);
			$sshopid=explode(",",$list['shopid']);
			foreach($sshopid as $kk=>$vv){
				$sshop[$kk]=M('shop')->find($vv);
			}
			$this->assign('sshop',$sshop);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改文章');
		}
		$this->display('article_edit');
	}
   
   function doarticle(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['state']=1;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('article')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/article'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('article')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/article'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delarticle(){
	    $ids = $_POST['ids'];
		$del = M('article')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	
  
	/**
	 * ------------------------------
	 * 自动保存 文章
	 * ------------------------------
	 */
	function auto_save_article(){
	    $id = $_POST['id'];
	    $con = $_POST['con'];
	    $obj = $_POST['obj'];
		$save['id']=$id;
		$save[$obj]=$con;
		
		if($id){
			$save['stime']=time();
			$cc=M('article')->save($save);
		}else{
			$save['ctime']=time();
			$save['stime']=time();
			$cc=M('article')->add($save);
		}
        echo $cc?$cc:'0';
	}	
	
	/**
	 * ------------------------------
	 * 文章-视频 管理
	 * ------------------------------
	 */
	function art_video(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('article_video')->where("aid=".$aid."")->select();
		$this->assign('list',$list);
		$this->assign('pagetitle', '视频');
		$this->display();
	}

	function editart_video(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/article'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('article_video')->where("aid=".$aid."")->count();
			if($list_num>=10){
				$this->assign('jumpUrl', U('Content/art_video',array(aid=>$aid)));
				$this->error('最多只能添加10个视频！');
			}
		     $this->assign('pagetitle', '添加视频');
		}else{
			 $list = M('article_video')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改视频');
		}
		$this->display('art_video_edit');
	}
   function doart_video(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/article'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('article_video')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/art_video',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('article_video')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/art_video',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delart_video(){
	    $ids = $_POST['ids'];
		$del = M('article_video')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	

	/**
	 * ------------------------------
	 * 文章-相片集 管理
	 * ------------------------------
	 */
	function art_photo_files(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('article_photo_files')->where("aid=".$aid."")->select();
		$this->assign('list',$list);
		$this->assign('pagetitle', '相片集');
		$this->display();
	}

	function editart_photo_files(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/article'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('article_photo_files')->where("aid=".$aid."")->count();
			if($list_num>=20){
				$this->assign('jumpUrl', U('Content/art_photo_files',array(aid=>$aid)));
				$this->error('最多只能添加20个相册！');
			}
		     $this->assign('pagetitle', '添加相片集');
		}else{
			 $list = M('article_photo_files')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改相片集');
		}
		$this->display('art_photo_files_edit');
	}
   function doart_photo_files(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/article'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('article_photo_files')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/art_photo_files',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('article_photo_files')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/art_photo_files',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delart_photo_files(){
	    $ids = $_POST['ids'];
		$del = M('article_photo_files')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	

	/**
	 * ------------------------------
	 * 文章-相片管理
	 * ------------------------------
	 */
	function art_photo(){
        $fid = intval($_GET['fid']);
		$this->assign('fid',$fid);
		$list = M('article_photo')->where("fid=".$fid."")->select();
		$this->assign('list',$list);
		$this->assign('pagetitle', '相片');
		$this->display();
	}

	function editart_photo(){
        $id = intval($_GET['id']);
        $fid = intval($_GET['fid']);
		$this->assign('fid',$fid);
		if(!$fid){
			$this->assign('jumpUrl', U('Content/article'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('article_photo')->where("fid=".$fid."")->count();
			if($list_num>=20){
				$this->assign('jumpUrl', U('Content/art_photo',array(fid=>$fid)));
				$this->error('最多只能添加20张相片！');
			}
		     $this->assign('pagetitle', '添加相片');
		}else{
			 $list = M('article_photo')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改相片');
		}
		$this->display('art_photo_edit');
	}
   function doart_photo(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $fid = intval($_POST['fid']);
		$this->assign('fid',$fid);
		if(!$fid){
			$this->assign('jumpUrl', U('Content/article'));
			$this->error('数据错误！');
		}
		$_POST['fid']=$fid;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('article_photo')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/art_photo',array(fid=>$fid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('article_photo')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/art_photo',array(fid=>$fid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delart_photo(){
	    $ids = $_POST['ids'];
		$del = M('article_photo')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	

	/**
	 * ------------------------------
	 * 商家管理
	 * ------------------------------
	 */
	function shop(){
	
		import("@.ORG.Page");
		$count	= M('shop')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('shop')->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '商家列表');
	
		$this->display();
	 }
	
	function editshop(){
        $id = intval($_GET['id']);
		if($id==''){
		     $this->assign('pagetitle', '添加商家');
		}else{
			 $list = M('shop')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改商家');
		}
		$this->display('shop_edit');
	}
   
   function doshop(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('shop')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delshop(){
	    $ids = $_POST['ids'];
		$del = M('shop')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	
  
	/**
	 * ------------------------------
	 * 自动保存 商家
	 * ------------------------------
	 */
	function auto_save_shop(){
	    $id = $_POST['id'];
	    $con = $_POST['con'];
	    $obj = $_POST['obj'];
		$save['id']=$id;
		$save[$obj]=$con;
		
		if($id){
			$save['stime']=time();
			$cc=M('shop')->save($save);
		}else{
			$save['ctime']=time();
			$save['stime']=time();
			$cc=M('shop')->add($save);
		}
        echo $cc?$cc:'0';
	}	
	/**
	 * ------------------------------
	 * 商家-top产品图 管理
	 * ------------------------------
	 */
	function shop_topphoto(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('shop_topphoto')->where("aid=".$aid."")->select();
		$this->assign('list',$list);
		$this->assign('pagetitle', 'top产品');
		$this->display();
	}

	function editshop_topphoto(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_topphoto')->where("aid=".$aid."")->count();
			if($list_num>=10){
				$this->assign('jumpUrl', U('Content/shop_topphoto',array(aid=>$aid)));
				$this->error('最多只能添加3张图！');
			}
		     $this->assign('pagetitle', '添加top产品');
		}else{
			 $list = M('shop_topphoto')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改top产品');
		}
		$this->display('shop_topphoto_edit');
	}
   function doshop_topphoto(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_topphoto')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_topphoto',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('shop_topphoto')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_topphoto',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delshop_topphoto(){
	    $ids = $_POST['ids'];
		$del = M('shop_topphoto')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	
	
	/**
	 * ------------------------------
	 * 商家-视频 管理
	 * ------------------------------
	 */
	function shop_video(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('shop_video')->where("aid=".$aid."")->select();
		$this->assign('list',$list);
		$this->assign('pagetitle', '视频');
		$this->display();
	}

	function editshop_video(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_video')->where("aid=".$aid."")->count();
			if($list_num>=10){
				$this->assign('jumpUrl', U('Content/shop_video',array(aid=>$aid)));
				$this->error('最多只能添加10个视频！');
			}
		     $this->assign('pagetitle', '添加视频');
		}else{
			 $list = M('shop_video')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改视频');
		}
		$this->display('shop_video_edit');
	}
   function doshop_video(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_video')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_video',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('shop_video')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_video',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delshop_video(){
	    $ids = $_POST['ids'];
		$del = M('shop_video')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	

	/**
	 * ------------------------------
	 * 商家-相片集 管理
	 * ------------------------------
	 */
	function shop_photo_files(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('shop_photo_files')->where("aid=".$aid."")->select();
		$this->assign('list',$list);
		$this->assign('pagetitle', '相片集');
		$this->display();
	}

	function editshop_photo_files(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_photo_files')->where("aid=".$aid."")->count();
			if($list_num>=20){
				$this->assign('jumpUrl', U('Content/shop_photo_files',array(aid=>$aid)));
				$this->error('最多只能添加20个相册！');
			}
		     $this->assign('pagetitle', '添加相片集');
		}else{
			 $list = M('shop_photo_files')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改相片集');
		}
		$this->display('shop_photo_files_edit');
	}
   function doshop_photo_files(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_photo_files')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_photo_files',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('shop_photo_files')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_photo_files',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delshop_photo_files(){
	    $ids = $_POST['ids'];
		$del = M('shop_photo_files')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	

	/**
	 * ------------------------------
	 * 商家-相片管理
	 * ------------------------------
	 */
	function shop_photo(){
        $fid = intval($_GET['fid']);
		$this->assign('fid',$fid);
		$list = M('shop_photo')->where("fid=".$fid."")->select();
		$this->assign('list',$list);
		$this->assign('pagetitle', '相片');
		$this->display();
	}

	function editshop_photo(){
        $id = intval($_GET['id']);
        $fid = intval($_GET['fid']);
		$this->assign('fid',$fid);
		if(!$fid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_photo')->where("fid=".$fid."")->count();
			if($list_num>=20){
				$this->assign('jumpUrl', U('Content/shop_photo',array(fid=>$fid)));
				$this->error('最多只能添加20张相片！');
			}
		     $this->assign('pagetitle', '添加相片');
		}else{
			 $list = M('shop_photo')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改相片');
		}
		$this->display('shop_photo_edit');
	}
   function doshop_photo(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $fid = intval($_POST['fid']);
		$this->assign('fid',$fid);
		if(!$fid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		$_POST['fid']=$fid;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_photo')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_photo',array(fid=>$fid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('shop_photo')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_photo',array(fid=>$fid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delshop_photo(){
	    $ids = $_POST['ids'];
		$del = M('shop_photo')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	

	/**
	 * ------------------------------
	 * 评论管理
	 * ------------------------------
	 */
	function pinglun(){
	
		import("@.ORG.Page");
		$count	= M('pinglun')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('pinglun')->order('id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '皮肤列表');
	
		$this->display();
	 }
	
	function editpinglun(){
        $id = intval($_GET['id']);
		if($id==''){
		     $this->assign('pagetitle', '添加皮肤');
		}else{
			 $list = M('pinglun')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改皮肤');
		}
		$this->display('pinglun_edit');
	}
   
   function dopinglun(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		

		if($_POST['id']){
				if( M('pinglun')->save($_POST) ){
					$this->assign('jumpUrl', U('Content/pinglun'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('pinglun')->add($_POST) ){
					$this->assign('jumpUrl', U('Content/pinglun'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function delpinglun(){
	    $ids = $_POST['ids'];
		$del = M('pinglun')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}

	/**
	 * ------------------------------
	 * 用户管理
	 * ------------------------------
	 */
	function user(){
	
		import("@.ORG.Page");
		$count	= M('user')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('user')->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '用户信息列表');
	
		$this->display();
	 }
	
	function edituser(){
        $id = intval($_GET['id']);
		$list1 = M('daren')->select();
	    $this->assign('list1', $list1);
		
		
		if($id==''){
		     $this->assign('pagetitle', '添加用户信息');
		}else{
			 $list = M('user')->find($id);
              if($list['xingbie']==0){
				  $list['xingbie']="男";  
			  }else{
				  $list['xingbie']="女"; 
			  }
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改用户信息');
		}
		$this->display('user_edit');
	}
   
   function douser(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		if($_POST['id']){
			
				if(!$_POST['getuijian']){
					$_POST['getuijian']="0";
					$_POST['gtime']="0";	
				}else{
					$_POST['gtime']=time();	
				}
				if(!$_POST['shoutuijian']){
					$_POST['shoutuijian']="0";	
					$_POST['stime']="0";
				}else{
					$_POST['stime']=time();	
				}

				
				if( M('user')->save($_POST) ){
					$this->assign('jumpUrl', U('Content/user'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('user')->add($_POST) ){
					$this->assign('jumpUrl', U('Content/user'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function deluser(){
	    $ids = $_POST['ids'];
		$del = M('user')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	
    /**
	 * ------------------------------
	 * 搜索用户昵称
	 * ------------------------------
	 */
	function searchuser(){
		 $name=$_REQUEST['name'];
		 $this->assign('name',$name);	 	
		import("@.ORG.Page");
		$count	= M('user')->where("nicheng like '%$name%'")->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('user')->where("nicheng like '%$name%'")->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();

		
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '搜索用户信息列表');
	
		$this->display('user');
	 }	  


 
	
}
?>